<!--conf
<sample in_favorites="false">
              <product version="1.4" edition="pro"/>
                     <modifications>
                            <modified date="070101"/>
                     </modifications>
               </sample>
 --> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Drag-and-drop events</title>

</head>

<body>
<link rel='STYLESHEET' type='text/css' href='../common/style.css'>
<table cellspacing="0" cellpadding="0" class="sample_header" border="0">
	<tr valign="middle">
		<!-- COMPONENT ICON -->
		<td width="40" align="center"><img src="../common/dhtmlxgrid_icon.gif" border="0"></td>
		<!-- COMPONENT NAME -->
		<td width="150" align="left" nowrap="true">Sample: dhtmlxGrid</td>
		<!-- SAMPLE TITLE -->
		<td width="0" align="left" nowrap><b>Drag-and-drop events</b></td>
		<!-- LINK TO COMPONENT PAGE -->
		<td width="0" align="right"><a href="http://www.dhtmlx.com/docs/products/dhtmlxGrid/index.shtml">dhtmlxGrid main page</a></td>
		<!-- CLOSE BUTTON -->
		<td width="50"><div class="sample_close"><a href="javascript:void(0);" onclick="self.close();"><img src="../common/sample_close.gif" width="14" height="14" border="0" alt="X"></a></div></td>
	</tr>
</table>
	
	

	<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
	<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid_skins.css">
	<script  src="../../codebase/dhtmlxcommon.js"></script>
	<script  src="../../codebase/dhtmlxgrid.js"></script>
	<script  src="../../codebase/ext/dhtmlxgrid_drag.js"></script>
	<script  src="../../codebase/dhtmlxgridcell.js"></script>
    <div >
	<table style="table-layout:fixed" width="775">
		<tr>
			<td valign="top" width="600">
				<div id="gridbox" width="100%" height="250px" style="background-color:white;"></div>
			</td>
			<td width="15"></td>
            <td valign="top"  width="150">
            <div style="height:250px; overflow:auto;" id="a11"></div>
            </td>
		</tr>
	</table>
    </div>
    <input type='checkbox' checked="checked" id='a22';> Allow drag-and-drop (used by onDrag event)
    <br/>
    <input type='checkbox' checked="checked" id='a23';> Allow landing
<br>
<div class='sample_code'><div class="hl-main"><pre><span class="hl-code"> 
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">div</span><span class="hl-code"> </span><span class="hl-var">id</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">gridbox</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">width</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">100%</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">height</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">250px</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">style</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">background-color:white;overflow:hidden</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">&gt;</span><span class="hl-brackets">&lt;/</span><span class="hl-reserved">div</span><span class="hl-brackets">&gt;</span><span class="hl-code">
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">script</span><span class="hl-brackets">&gt;</span><span class="hl-code"><div class="hl-main"><pre><span class="hl-code"> 
 
  </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">drag_f</span><span class="hl-brackets">(</span><span class="hl-identifier">r1</span><span class="hl-code">,</span><span class="hl-identifier">r2</span><span class="hl-brackets">)</span><span class="hl-brackets">{</span><span class="hl-code">
    </span><span class="hl-builtin">document</span><span class="hl-code">.</span><span class="hl-identifier">getElementById</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">a11</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">.</span><span class="hl-identifier">innerHTML</span><span class="hl-code">+=</span><span class="hl-quotes">&quot;</span><span class="hl-string">Item &lt;b&gt;</span><span class="hl-quotes">&quot;</span><span class="hl-code">+</span><span class="hl-identifier">r1</span><span class="hl-code">+</span><span class="hl-quotes">&quot;</span><span class="hl-string">&lt;/b&gt; draged on item &lt;b&gt;</span><span class="hl-quotes">&quot;</span><span class="hl-code">+</span><span class="hl-identifier">r2</span><span class="hl-code">+</span><span class="hl-quotes">&quot;</span><span class="hl-string">&lt;/b&gt;&lt;br/&gt;</span><span class="hl-quotes">&quot;</span><span class="hl-code">;
    </span><span class="hl-reserved">return</span><span class="hl-code"> </span><span class="hl-builtin">document</span><span class="hl-code">.</span><span class="hl-identifier">getElementById</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">a22</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">.</span><span class="hl-identifier">checked</span><span class="hl-code">;
  </span><span class="hl-brackets">}</span><span class="hl-code">
  </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">drop_f</span><span class="hl-brackets">(</span><span class="hl-identifier">r1</span><span class="hl-code">,</span><span class="hl-identifier">r2</span><span class="hl-brackets">)</span><span class="hl-brackets">{</span><span class="hl-code">
    </span><span class="hl-builtin">document</span><span class="hl-code">.</span><span class="hl-identifier">getElementById</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">a11</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">.</span><span class="hl-identifier">innerHTML</span><span class="hl-code">+=</span><span class="hl-quotes">&quot;</span><span class="hl-string">Item &lt;b&gt;</span><span class="hl-quotes">&quot;</span><span class="hl-code">+</span><span class="hl-identifier">r1</span><span class="hl-code">+</span><span class="hl-quotes">&quot;</span><span class="hl-string">&lt;/b&gt; droped on item &lt;b&gt;</span><span class="hl-quotes">&quot;</span><span class="hl-code">+</span><span class="hl-identifier">r2</span><span class="hl-code">+</span><span class="hl-quotes">&quot;</span><span class="hl-string">&lt;/b&gt;&lt;br/&gt;</span><span class="hl-quotes">&quot;</span><span class="hl-code">;
  </span><span class="hl-brackets">}</span><span class="hl-code">
 
        </span><span class="hl-identifier">mygrid</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">dhtmlXGridObject</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">gridbox</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
        ...
        </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachEvent</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">onDrag</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-identifier">drag_f</span><span class="hl-brackets">)</span><span class="hl-code">;
       </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachEvent</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">onDragIn</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-identifier">drag_in</span><span class="hl-brackets">)</span><span class="hl-code">;
      </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachEvent</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">onDrop</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-identifier">drop_f</span><span class="hl-brackets">)</span><span class="hl-code">;
        </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">loadXML</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">gridH.xml</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;</span></pre></div></span><span class="hl-brackets">&lt;/</span><span class="hl-reserved">script</span><span class="hl-brackets">&gt;</span></pre></div></div>

<script>
  function drag_f(r1,r2){
    document.getElementById("a11").innerHTML+="Item <b>"+r1+"</b> draged on item <b>"+r2+"</b><br/>";
    return document.getElementById("a22").checked;
  }
  function drag_in(r1,r2){
    document.getElementById("a11").innerHTML+="Item <b>"+r1+"</b> draged over <b>"+r2+"</b><br/>";
    return document.getElementById("a23").checked;
  }
  function drop_f(r1,r2){
    document.getElementById("a11").innerHTML+="Item <b>"+r1+"</b> droped on item <b>"+r2+"</b><br/>";
  }
  function buildGrid(mygrid){
	mygrid.setImagePath("../../codebase/imgs/");
	mygrid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
	mygrid.setInitWidths("50,150,100,80,80,80,80,200")
	mygrid.setColAlign("right,left,left,right,center,left,center,center")
	mygrid.setColTypes("dyn,ed,ed,price,ch,co,ra,ro");
	mygrid.setColSorting("int,str,str,int,str,str,str,date")
    mygrid.enableMultiselect(true);
	mygrid.init();
    mygrid.enableDragAndDrop(true);
    mygrid.attachEvent("onDrag",drag_f);
    mygrid.attachEvent("onDragIn",drag_in);
  mygrid.attachEvent("onDrop",drop_f);
	mygrid.setSkin("modern")
	mygrid.loadXML("grid.xml");

    }
	mygrid = new dhtmlXGridObject('gridbox');
    buildGrid(mygrid);
</script>

<!-- FOOTER -->
<table callspacing="0" cellpadding="0" border="0" class="sample_footer"><tr><td style="padding-left: 8px;">&copy; <a href="http://www.dhtmlx.com">DHTMLX LTD</a>. All rights reserved</td></tr></table>
<!-- FOOTER -->

</body>
</html>
